/*
   Copyright (C) 2009 Klaus Blindert <klaus.blindert@web.de>

   Part of the libABF project.

   libABF is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the
   Free Software Foundation, Inc.,
   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
*/
#ifndef ABF_UTIL_H
#define ABF_UTIL_H

/**
 * @file abf_util.h
 * @author Klaus Blindert <klaus.blindert@web.de>
 *
 * @brief Various internals
 */

#include "abf_types.h"

#include <assert.h>

#define HERE __FUNCTION__

void* abf_alloc(const char* function, unsigned needed);
void* abf_realloc(const char* function, void* data, unsigned have, unsigned needed);
int abf_read_into (const char* filename, char** buffer, uint32_t* capacity, uint32_t* size);

#define CHECK_FLAT(flat) assert( flat != 0 )
#define CHECK_DATA(data) assert( data != 0 )
#define CHECKED_ALLOC(size) abf_alloc(HERE, size);
#define CHECKED_REALLOC(data,have,size) abf_realloc(HERE, data, have, size);

#endif /* ABF_UTIL_H */
